package cn.tedu.redissondemo.controller;

public class Test1 {
    private static Integer lock = 3;
    public  void a()  {
        synchronized (lock){
            System.out.println("a");
            try {
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }
    public  void b(){
        synchronized (lock) {
            System.out.println("b");
            try {
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args) {
        Test1 t = new Test1();
        Test1 t3 = new Test1();
        Thread t1 =new Thread(){
            @Override
            public void run() {
                t.a();
            }
        };
        Thread t2 =new Thread(){
            @Override
            public void run() {
                t3.b();
            }
        };
        t1.start();
        t2.start();
    }
}
